﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CE.User;
using CE.Global;
using CE.TravelInsurance;
using CE.AreaCountry;

public partial class travel_insurance_ViewCompletedTravelInsuranceDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] != null && Session[CE.Global.General.UserTypeId] != null)
        {
            if (Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                Convert.ToInt32(CE.Global.CEUserType.Customer) && Convert.ToInt32(Session[CE.Global.General.UserTypeId]) !=
                Convert.ToInt32(CE.Global.CEUserType.Provider))
            {
                Response.Redirect("~/car-insurance/login.aspx");
            }
        }
        else
        {
            Response.Redirect("~/car-insurance/login.aspx");
        }

        if (Page.Request.Params["ResultId"] != null)
        {
            Int64 _tempResultId = 0;
            Int64 _taId = 0;
            if (Int64.TryParse(Page.Request.Params["ResultId"], out _tempResultId))
            {
                _taId = CheckCompleteStatus(_tempResultId);
                if (_taId > 0)
                {
                    ShowDetails(_taId);
                }
                else
                {
                    Response.Redirect("~/user/viewresulthistory.aspx");
                }
            }
            else
            {
                Response.Redirect("~/user/viewresulthistory.aspx");
            }
        }
        else
        {
            Response.Redirect("~/user/viewresulthistory.aspx");
        }
    }

    private Int64 CheckCompleteStatus(Int64 _resultId)
    {
        UserResultHistory _result = new UserResultHistory();
        UserResultHistoryDB _resultdb = new UserResultHistoryDB();
        Int64 _taId = 0;
        _result = _resultdb.GetResultHistory(Convert.ToInt64(Session[General.UserId].ToString()), _resultId);
        if (_result != null && _result.IsComplete)
        {
            _taId = _result.ID1;
        }

        return _taId;
    }

    private void ShowDetails(Int64 _taId)
    {
        string _refNo = General.GetRefNumber(_taId);
        TAApplicantSearch _taapplicant = new TAApplicantSearch();
        TAApplicantSearchDB _taapplicantdb = new TAApplicantSearchDB();

        CE.Database.MyDatabase _db = new CE.Database.MyDatabase();

        Int64 _refCEUserId = Convert.ToInt64(Session[General.UserId].ToString());
        _taapplicant = _taapplicantdb.GetTAApplicantSearchItem(_taId);

        if (_taapplicant != null)
        {

            //lblDOB.Text = String.Format("{0:dd/MM/yyyy}", _taapplicant.DOBAdult1);
            lblPolicyType.Text = GetPolicy(_taapplicant.PlanType.ToString());
            lblCoverageType.Text = GetCoverage(_taapplicant.TripType.ToString());
            lblNoOfTravellers.Text = _taapplicant.NoOfTravellers.ToString();
            lblTotalPremium.Text = "$ " + _taapplicant.TotalPremium.ToString();

            if (_taapplicant.TripType == "A")
            {
                lblPeriodOfCoverage.Text = String.Format("{0:dd/MM/yyyy}", _taapplicant.StartDate);
                lblStart.Text = _taapplicant.StartDate.ToString();
                lblEnd.Text = _taapplicant.StartDate.ToString();
            }
            else
            {
                lblPeriodOfCoverage.Text = String.Format("{0:dd/MM/yyyy} To {1:dd/MM/yyyy}", _taapplicant.StartDate, _taapplicant.EndDate);
                lblStart.Text = _taapplicant.StartDate.ToString();
                lblEnd.Text = _taapplicant.EndDate.ToString();

            }


        }


        Int64 _companyId = 0;

        System.Data.DataTable _dtSeletectItem = new System.Data.DataTable("SelectedResultItem");
        _dtSeletectItem = _db.GetDataTable("Select * from tblTAInsuranceSelectItem WHERE RefCEUserId = " + _refCEUserId.ToString() + " And CETAId = " + _taId.ToString());
        if (_dtSeletectItem != null && _dtSeletectItem.Rows.Count > 0)
        {
            _companyId = Convert.ToInt64(_dtSeletectItem.Rows[0]["ProviderCompanyId"].ToString());


        }

        if (_companyId == 29)
        {
            TAMoreDetailLiberty _taliberty = new TAMoreDetailLiberty();
            TAMoreDetailLibertyDB _talibertydb = new TAMoreDetailLibertyDB();

            _taliberty = _talibertydb.GetTAMoreDetail(_taId, _refCEUserId);
            lblInsurer.Text = "Liberty Insurance";

            lblQuoteTitle.Text = "Quote Ref No : TIL" + _refNo + " - Travel Insurance (" + lblPolicyType.Text + " )";
            if (_taliberty != null)
            {
                lblDestination.Text = _taliberty.Country;
                lblName.Text = _taliberty.Name;
                lblGender.Text = _taliberty.Gender;
                lblBirthday.Text = String.Format("{0:dd/MM/yyyy}", _taliberty.DOB);
                lblAddress.Text = "#" + _taliberty.UnitNo.ToString() + "-" + _taliberty.HomeNo + "<br />" + _taliberty.Address;
                lblContactNo.Text = _taliberty.MobileNo;
                lblNRICNo.Text = _taliberty.NRICNo;
                lblNationality.Text = _taliberty.Nationality;

                System.Data.DataTable _dtMaritalStatus = new System.Data.DataTable("MaritalStatusInfo");
                _dtMaritalStatus = _db.GetDataTable("Select Description from tblMaritalStatusInfo Where MaritalStatusId = " + _taliberty.MaritalStatus);
                if (_dtMaritalStatus != null && _dtMaritalStatus.Rows.Count > 0)
                {
                    lblMaritalStatus.Text = _dtMaritalStatus.Rows[0]["Description"].ToString();
                }
                _dtMaritalStatus = null;

                System.Data.DataTable _dtOccupation = new System.Data.DataTable("OccupationInfo");
                _dtOccupation = _db.GetDataTable("Select Description from tblOccupationInfo Where OccupationId = " + _taliberty.Occupation);
                if (_dtOccupation != null && _dtOccupation.Rows.Count > 0)
                {
                    lblOccupation.Text = _dtOccupation.Rows[0]["Description"].ToString();
                }
                _dtOccupation = null;

                divGender.Visible = true;
                divMaritalStatus.Visible = true;
                divBirthday.Visible = true;
                divOccupation.Visible = true;
                divNRIC.Visible = true;

                divHSBCInsured1.Visible = false;
                divHSBCInsured2.Visible = false;
            }
        }
        else if (_companyId == 23)
        {
            TAMoreDetailHsbc _tahsbc = new TAMoreDetailHsbc();
            TAMoreDetailHsbcDB _tahsbcdb = new TAMoreDetailHsbcDB();
            _tahsbc = _tahsbcdb.GetTAMoreDetail(_taId, _refCEUserId);
            lblInsurer.Text = "HSBC Insurance";
            lblQuoteTitle.Text = "Quote Ref No : TIH" + _refNo + " - Travel Insurance (" + lblPolicyType.Text + " )";

            if (_tahsbc != null)
            {
                lblDestination.Text = _tahsbc.Country;
                lblName.Text = _tahsbc.Name;
                lblAddress.Text = "#" + _tahsbc.UnitNo.ToString() + "-" + _tahsbc.HomeNo + "<br />" + _tahsbc.Address;
                lblContactNo.Text = _tahsbc.MobileNo;
                lblNRICNo.Text = _tahsbc.NRICNo;
                lblNationality.Text = _tahsbc.Nationality;

                //hide 
                divGender.Visible = false;
                divMaritalStatus.Visible = false;
                divBirthday.Visible = false;
                divOccupation.Visible = false;
                divNRIC.Visible = false;


            }

            System.Data.DataTable _dtInsured = new System.Data.DataTable("Insured");
            _dtInsured = _db.GetDataTable("Select * from tblTATravellersToInsure WHERE RefCEUserId = " + _refCEUserId.ToString() + "And Info1 = 'HSBC' And TAPersonnelId = " + _tahsbc.cetaMoreDetailId.ToString());
            if (_dtInsured != null && _dtInsured.Rows.Count > 0)
            {

                divHSBCInsured2.Visible = false;
                divChild1.Visible = false;
                divChild2.Visible = false;
                divChild3.Visible = false;
                divChild4.Visible = false;
                divChild5.Visible = false;
                divChild6.Visible = false;
                for(int i = 0; i < _dtInsured.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        lblInsuredName.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 1)
                    {
                        divHSBCInsured2.Visible = true;
                        lblInsuredName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 2)
                    {
                        divChild1.Visible = true;
                        lblChildName1.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 3)
                    {
                        divChild2.Visible = true;
                        lblChildName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 4)
                    {
                        divChild3.Visible = true;
                        lblChildName3.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB3.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC3.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 5)
                    {
                        divChild4.Visible = true;
                        lblChildName4.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB4.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC4.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 6)
                    {
                        divChild5.Visible = true;
                        lblChildName5.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB5.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC5.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 7)
                    {
                        divChild6.Visible = true;
                        lblChildName6.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB6.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC6.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                }
                //if (_dtInsured.Rows.Count == 1)
                //{
                //    divHSBCInsured1.Visible = true;
                //    divHSBCInsured2.Visible = false;
                //}
                //else
                //{
                //    divHSBCInsured2.Visible = true;

                //    lblInsuredName2.Text = _dtInsured.Rows[1]["Fullname"].ToString();
                //    lblBirthday2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[1]["Birthday"].ToString())); ;
                //    lblNRICPassport2.Text = _dtInsured.Rows[1]["IdentificationNum"].ToString();
                //}

                //lblInsuredName.Text = _dtInsured.Rows[0]["Fullname"].ToString();
                //lblBirthday1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[0]["Birthday"].ToString())); ;
                //lblNRICPassport1.Text = _dtInsured.Rows[0]["IdentificationNum"].ToString();

            }

        }
      
        else if (_companyId == 34)
        {
            TAMoreDetailChinaTaiping _tachina = new TAMoreDetailChinaTaiping();
            TAMoreDetailChinaTaipingDB _tachinadb = new TAMoreDetailChinaTaipingDB();

            _tachina = _tachinadb.GetTAMoreDetail(_taId, _refCEUserId);
            lblInsurer.Text = "China Taiping Insurance";
            lblQuoteTitle.Text = "Quote Ref No : TIC" + _refNo + " - Travel Insurance (" + lblPolicyType.Text + " )";

            if (_tachina != null)
            {
                lblDestination.Text = _tachina.Country;
                lblName.Text = _tachina.Name;
                lblAddress.Text = "#" + _tachina.UnitNo.ToString() + "-" + _tachina.HomeNo + "<br />" + _tachina.Address;
                lblContactNo.Text = _tachina.MobileNo;
                lblNRICNo.Text = _tachina.NRICNo;
                lblNationality.Text = _tachina.Nationality;

                //hide 
                divGender.Visible = false;
                divMaritalStatus.Visible = false;
                divBirthday.Visible = false;
                divOccupation.Visible = false;
                divNRIC.Visible = false;


            }

            System.Data.DataTable _dtInsured = new System.Data.DataTable("Insured");
            _dtInsured = _db.GetDataTable("Select * from tblTATravellersToInsure WHERE RefCEUserId = " + _refCEUserId.ToString() + "And Info1 = 'ChinaT' And TAPersonnelId = " + _tachina.cetaMoreDetailId.ToString());
            if (_dtInsured != null && _dtInsured.Rows.Count > 0)
            {

                divHSBCInsured2.Visible = false;
                divChild1.Visible = false;
                divChild2.Visible = false;
                divChild3.Visible = false;
                divChild4.Visible = false;
                divChild5.Visible = false;
                divChild6.Visible = false;
                for (int i = 0; i < _dtInsured.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        lblInsuredName.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 1)
                    {
                        divHSBCInsured2.Visible = true;
                        lblInsuredName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 2)
                    {
                        divChild1.Visible = true;
                        lblChildName1.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 3)
                    {
                        divChild2.Visible = true;
                        lblChildName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 4)
                    {
                        divChild3.Visible = true;
                        lblChildName3.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB3.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC3.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 5)
                    {
                        divChild4.Visible = true;
                        lblChildName4.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB4.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC4.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 6)
                    {
                        divChild5.Visible = true;
                        lblChildName5.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB5.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC5.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 7)
                    {
                        divChild6.Visible = true;
                        lblChildName6.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB6.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC6.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                }


            }

        }
        else if (_companyId == 35)
        {
            TAMoreDetailEq _taeq = new TAMoreDetailEq();
            TAMoreDetailEqDB _taeqdb = new TAMoreDetailEqDB();

            _taeq = _taeqdb.GetTAMoreDetail(_taId, _refCEUserId);
            lblInsurer.Text = "EQ Insurance";
            lblQuoteTitle.Text = "Quote Ref No : TIQ" + _refNo + " - Travel Insurance (" + lblPolicyType.Text + " )";

            if (_taeq != null)
            {
                lblDestination.Text = _taeq.Country;
                lblName.Text = _taeq.Name;
                lblAddress.Text = "#" + _taeq.UnitNo.ToString() + "-" + _taeq.HomeNo + "<br />" + _taeq.Address;
                lblContactNo.Text = _taeq.MobileNo;
                lblNRICNo.Text = _taeq.NRICNo;
                lblNationality.Text = _taeq.Nationality;

                //hide 
                divGender.Visible = false;
                divMaritalStatus.Visible = false;
                divBirthday.Visible = false;
                divOccupation.Visible = false;
                divNRIC.Visible = false;


            }

            System.Data.DataTable _dtInsured = new System.Data.DataTable("Insured");
            _dtInsured = _db.GetDataTable("Select * from tblTATravellersToInsure WHERE RefCEUserId = " + _refCEUserId.ToString() + "And Info1 = 'EQ' And TAPersonnelId = " + _taeq.cetaMoreDetailId.ToString());
            if (_dtInsured != null && _dtInsured.Rows.Count > 0)
            {

                divHSBCInsured2.Visible = false;
                divChild1.Visible = false;
                divChild2.Visible = false;
                divChild3.Visible = false;
                divChild4.Visible = false;
                divChild5.Visible = false;
                divChild6.Visible = false;
                for (int i = 0; i < _dtInsured.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        lblInsuredName.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 1)
                    {
                        divHSBCInsured2.Visible = true;
                        lblInsuredName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 2)
                    {
                        divChild1.Visible = true;
                        lblChildName1.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 3)
                    {
                        divChild2.Visible = true;
                        lblChildName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 4)
                    {
                        divChild3.Visible = true;
                        lblChildName3.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB3.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC3.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 5)
                    {
                        divChild4.Visible = true;
                        lblChildName4.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB4.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC4.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 6)
                    {
                        divChild5.Visible = true;
                        lblChildName5.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB5.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC5.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 7)
                    {
                        divChild6.Visible = true;
                        lblChildName6.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB6.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC6.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                }


            }

        }
        else if (_companyId == 36)
        {
            TAMoreDetailAce _taace = new TAMoreDetailAce();
            TAMoreDetailAceDB _taacedb = new TAMoreDetailAceDB();

            _taace = _taacedb.GetTAMoreDetail(_taId, _refCEUserId);
            lblInsurer.Text = "ACE Insurance";
            lblQuoteTitle.Text = "Quote Ref No : TIA" + _refNo + " - Travel Insurance (" + lblPolicyType.Text + " )";

            if (_taace != null)
            {
                lblDestination.Text = _taace.Country;
                lblName.Text = _taace.Name;
                lblAddress.Text = "#" + _taace.UnitNo.ToString() + "-" + _taace.HomeNo + "<br />" + _taace.Address;
                lblContactNo.Text = _taace.MobileNo;
                lblNRICNo.Text = _taace.NRICNo;
                lblNationality.Text = _taace.Nationality;

                //hide 
                divGender.Visible = false;
                divMaritalStatus.Visible = false;
                divBirthday.Visible = false;
                divOccupation.Visible = false;
                divNRIC.Visible = false;


            }

            System.Data.DataTable _dtInsured = new System.Data.DataTable("Insured");
            _dtInsured = _db.GetDataTable("Select * from tblTATravellersToInsure WHERE RefCEUserId = " + _refCEUserId.ToString() + "And Info1 = 'ACE' And TAPersonnelId = " + _taace.cetaMoreDetailId.ToString());
            if (_dtInsured != null && _dtInsured.Rows.Count > 0)
            {

                divHSBCInsured2.Visible = false;
                divChild1.Visible = false;
                divChild2.Visible = false;
                divChild3.Visible = false;
                divChild4.Visible = false;
                divChild5.Visible = false;
                divChild6.Visible = false;
                for (int i = 0; i < _dtInsured.Rows.Count; i++)
                {
                    if (i == 0)
                    {
                        lblInsuredName.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 1)
                    {
                        divHSBCInsured2.Visible = true;
                        lblInsuredName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblBirthday2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblNRICPassport2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 2)
                    {
                        divChild1.Visible = true;
                        lblChildName1.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB1.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC1.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 3)
                    {
                        divChild2.Visible = true;
                        lblChildName2.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB2.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC2.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 4)
                    {
                        divChild3.Visible = true;
                        lblChildName3.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB3.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC3.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 5)
                    {
                        divChild4.Visible = true;
                        lblChildName4.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB4.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC4.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 6)
                    {
                        divChild5.Visible = true;
                        lblChildName5.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB5.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC5.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                    if (i == 7)
                    {
                        divChild6.Visible = true;
                        lblChildName6.Text = _dtInsured.Rows[i]["Fullname"].ToString();
                        lblChildDOB6.Text = String.Format("{0:dd/MM/yyyy}", Convert.ToDateTime(_dtInsured.Rows[i]["Birthday"].ToString())); ;
                        lblChildNRIC6.Text = _dtInsured.Rows[i]["IdentificationNum"].ToString();
                    }
                }


            }

        }

    }

    protected string GetPolicy(string covertype)
    {
        string policy = "family";

        if (covertype == "IND")
        {
            policy = "Individual";
        }
        else if (covertype == "INS")
        {
            policy = "Individual + Spouse";
        }
        else if (covertype == "INC")
        {
            policy = "Individual + Child";
        }
        else if (covertype == "FML")
        {
            policy = "Family";
        }

        return policy;
    }

    protected string GetCoverage(string coverage)
    {
        string cover = "Single Trip";

        if (coverage == "A")
            cover = "Annual Multi-trip";

        return cover;
    }

    protected void ibtnBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/user/viewresulthistory.aspx");
    }
}
